home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / BLINE.INC < prev    next >
Text File  |  1989-06-07  |  2KB  |  50 lines

  1.  
  2. (*************************************************************************
  3. An Inline() implementation Boyer-Moore Algorithm for use with Turbo Pascal.
  4. by Don Strenczewilk, CIS 72617,132
  5.  
  6. I am not attempting to describe the Boyer-Moore algorithm
  7. here, just implement it in Inline().  If you want to know
  8. more about it, get Van Hall's BOYER.PAS in the BORPRO
  9. MS/PCDOS Data library which has an excellent description.
  10. It's usefullnes is to quickly search for strings in buffers.
  11.  
  12. (Mods for Turbo Pascal 5.0, S.H.Smith 7-Jun-89)
  13. *************************************************************************)
  14.  
  15.  
  16. {------------------------ Necessary Type Declarations -------------------------}
  17. TYPE
  18.   BTable = ARRAY[#0..#255] OF Byte;
  19.  
  20.   {-------- Make table of increments for the Boyer-Moore algorithm -----------}
  21.   PROCEDURE MakeTable(VAR SrchSt : string;
  22.                       VAR cray : BTable);
  23.     { makes table of increments for the Boyer-Moore algorithm }
  24.   BEGIN
  25.     INLINE($1E/$C5/$76/< SrchSt/$89/$F3/$8A/$04/$88/$C4/$B9/
  26.       $80/$00/$C4/$7E/< cray/$89/$FA/$FC/$F2/$AB/$89/$DE/$89/$D7/
  27.       $46/$98/$3C/$01/$7E/$13/$48/$88/$E1/$88/$E7/$8A/$1C/$89/
  28.       $C2/$29/$CA/$88/$11/$46/$41/$39/$C1/$75/$F2/$1F);
  29.   END;
  30.  
  31.   {---------- Case Insensitive version of Boyer-Moore algorithm --------------}
  32.   FUNCTION BMsearch(VAR buffr;
  33.               bsize : Integer;
  34.               VAR table;
  35.               VAR SrchSt : string) : Integer;
  36.     { Case Insensitive version of Boyer-Moore algorithm }
  37.     { SrchStr must be uppercased }
  38.   BEGIN
  39.     INLINE($1E/$31/$C0/$89/$C2/$C5/$76/< SrchSt/$8A/$14/$84/
  40.       $D2/$74/$63/$01/$D6/$FE/$CA/$C4/$7E/< buffr/$89/$F9/$03/
  41.       $8E/> bsize/$49/$01/$D7/$8A/$34/$C5/$5E/< table/$EB/$03/
  42.       $D7/$01/$C7/$39/$F9/$72/$45/$26/$8A/$05/$3C/$61/$72/$06/
  43.       $3C/$7A/$77/$02/$24/$DF/$38/$C6/$75/$E8/$56/$57/$51/$88/
  44.       $D1/$88/$E5/$81/$F9/$00/$00/$74/$13/$4E/$4F/$26/$8A/$05/
  45.       $3C/$61/$72/$06/$3C/$7A/$77/$02/$24/$DF/$3A/$04/$E1/$ED/
  46.       $88/$F0/$59/$5F/$5E/$75/$C1/$C4/$46/< buffr/$97/$30/$F6/
  47.       $29/$F8/$29/$D0/$40/$EB/$02/$30/$C0/$89/$46/$FE/$1F);
  48.   END;
  49.  
  50.